import { createRouter, createWebHistory } from 'vue-router'
import Dashboard from '../views/Dashboard.vue'
import Demo from '../views/Demo.vue'

const routes = [

  { path: '/demo', component: Demo,exact: true  },
 
  { path: '/dash', component: Dashboard,exact: true  }
  // 可继续添加更多 SPA 子页面
]

const router = createRouter({
  history: createWebHistory('/admin/spa/'),  // 设置基础路径
  routes
})

router.beforeEach((to, from, next) => {
  if (to.path === '/dash' && from.path === '/pageB') {
    // 这里可以做特殊处理，比如鉴权、数据刷新等
    next(); // 允许跳转
  } else {
    next(); // 默认允许跳转
  }
});

export default router